package org.liao.springboot.webservice.rs.cxf;

import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;
import org.apache.cxf.Bus;
import org.apache.cxf.endpoint.Server;
import org.apache.cxf.feature.LoggingFeature;
import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.annotation.Resource;
import java.util.Arrays;

//todo https://gitee.com/apache/cxf/blob/master/distribution/src/main/release/samples/jax_rs/spring_boot/src/main/java/sample/rs/service/SampleRestApplication.java
@Configuration
public class RSWebServerConfig {

//    @Autowired
//    private Bus bus;
//    @Resource(name="helloService1")
//    private HelloService helloService1;
//    @Resource(name="helloService2")
//    private HelloService helloService2;
//    @Bean
//    public Server rsServer() {
//        JAXRSServerFactoryBean endpoint = new JAXRSServerFactoryBean();
//        endpoint.setBus(bus);
//        endpoint.setServiceBeans(Arrays.<Object>asList(helloService1, helloService2));
//        endpoint.setAddress("/");
//        endpoint.setFeatures(Arrays.asList(new LoggingFeature()));
//        return endpoint.create();
//    }
    @Bean
    public LoggingFeature logingFeatures(){
        return new LoggingFeature();
    }
    @Bean
    public JacksonJsonProvider jacksonJsonProvider(){
        return new JacksonJsonProvider();
    }
}
